/**
 * @file GetContactsMessage.cs
 * @author Zane Mayo
 * @date 6/5/2009
 */

using System;
using System.Collections.Generic;

namespace MxitAPI {
	
	
	public class RawContact {
		public string Group { get; set; }
		public string ContactAddress { get; set; }
		public string NickName { get; set; }
		public Presence Presence { get; set; }
		public ContactType ContactType { get; set; }
		public Mood Mood { get; set; }
		
		public RawContact() {
		}
	}
	
	public class GetContactsProtocolMessage : ProtocolMessage {
		
		private static log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );
		
		public List<RawContact> RawContacts { get; set; }
		
		public GetContactsProtocolMessage() : base( 3 ) {
			RawContacts = new List<RawContact>();
		}
		
		public override void SetResponse( string[][] response ) {
			log.Debug( "Response to set get contacts message to: " + response.ToString() );
			for ( int i = 2 ; i < response.Length ; ++i ) {
				// Check that all the fields for the the contact details are there
				if ( response[i].Length < 6 )
					continue;
				RawContact rawContact = new RawContact();
				rawContact.Group = response[i][0];
				rawContact.ContactAddress = response[i][1];
				rawContact.NickName = response[i][2];
				rawContact.Presence = ( Presence ) Int32.Parse( response[i][3] );
				rawContact.ContactType = (ContactType) Int32.Parse( response[i][4] );
				rawContact.Mood = ( Mood ) Int32.Parse( response[i][5] );
				RawContacts.Add( rawContact );
			}
		}
		
		
	}
}
